package demo2;

public class OuterClass2 {
    public int demo1;
    private int demo2;
    public static int demo3;

    //非静态内部类(实例内部类对象)
    class InnerClass {
        public int demo4;
        private int demo5;

       // public static int demo6;  非静态内部类(实例内部类对象)  不能定义静态成员变量
        public static final int demo6 = 6;

        public void fun() {
            System.out.println(demo1);
            System.out.println(demo2);
            System.out.println(demo3);
            System.out.println(demo4);
            System.out.println(demo5);
            System.out.println(demo6);
        }
    }

    public void fun() {
        InnerClass innerClass = new InnerClass();

        System.out.println(this.demo1); //内部类自己的demo1
        System.out.println(OuterClass2.this.demo1); //外部类的demo1

        System.out.println(demo1);
        System.out.println(demo2);
        System.out.println(demo3);

        System.out.println(innerClass.demo4);
        System.out.println(innerClass.demo5);

        System.out.println(InnerClass.demo6);//静态变量  可以直接通过类名访问


    }
}
